@include('admin::layouts.header')
<div class="admin-main layui-anim layui-anim-upbit">
	<fieldset class="layui-elem-field layui-field-title">
		<legend>添加</legend>
	</fieldset>
	<form class="layui-form layui-form-pane" lay-filter="form">
		<div class="layui-form-item">
			<label class="layui-form-label">图片类型</label>
			<div class="layui-input-4">
				<select name="type" lay-verify="required" lay-filter="type_list">
					<option value="">请选择</option>
					@foreach($type_lists as $k=>$v)
					<option value="{{$k}}">{{$v}}</option> 
					@endforeach
				</select>
			</div>
		</div>
		@include('admin::layouts.create_html_image',['name'=>'图片','adPic'=>'adPic','image_id'=>'image_id','adBtn'=>'adBtn'])
		
		
		<div class="layui-form-item" style="display:none;" id="product_status_item">
			<label class="layui-form-label">是否为商品</label>
			<div class="layui-input-4">
				<select name="product_status" lay-filter="product_status">
					<option value="">请选择</option>
					@foreach($product_status_list as $k=>$v)
					<option value="{{$k}}">{{$v}}</option> 
					@endforeach
				</select>
			</div>
		</div>
		
		<div class="layui-form-item" style="display:none;" id="product_item">
			<label class="layui-form-label">商品</label>
			<div class="layui-input-4">
				<select name="product_id" lay-search="">
					<option value="">请选择</option>
					@foreach($shop_product_list as $k=>$v)
					<option value="{{$v->id}}">{{$v->name}}</option> 
					@endforeach
				</select>
			</div>
		</div>
		<div id="product_content_item" style="display:none;margin-top:150px;">
			@include('admin::layouts.create_ue',['name'=>'详情','id'=>'product_content'])
		</div>
		
		
		<div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-2">
                <input type="text" onkeyup="this.value=this.value.replace(/\D/gi,&quot;&quot;)" maxlength="11" name="sort" value="1" placeholder="请输入排序编号" lay-verify="required" class="layui-input">
            </div>
        </div>
		@include('admin::layouts.submit',['url'=>route('admin.picture.index')])
	</form>
</div>
@include('admin::layouts.footer')
@include('admin::layouts.create_ajax',['url'=>route('admin.picture.store')])
@include('admin::layouts.create_ajax_image',['url'=>route('admin.upload.upload_file'),'adPic'=>'#adPic','image_id'=>'#image_id','adBtn'=>'#adBtn'])
 <script>
	layui.use(['form', 'layer'], function () {
        var form = layui.form,layer = layui.layer,$= layui.jquery;
		form.verify({	
			image_id: function(value){  
				if(value == ''){  
					return '请上传图片！';  
				}  
			}	
		});
		form.on('select(type_list)', function(data){
			var type = data.value;
			if(type == 2 || type == 3){
				$('#product_status_item').show();
				$('#product_content_item').hide();
				$('#product_item').hide();
			}else{
				$('#product_status_item').hide();
				$('#product_content_item').hide();
				$('#product_item').hide();
			}
        });
		form.on('select(product_status)', function(data){
			var product_status = data.value;
			if(product_status == 1){
				$('#product_item').hide();
				$('#product_content_item').show();
			}else if(product_status == 2){
				$('#product_item').show();
				$('#product_content_item').hide();
			}else{
				$('#product_content_item').hide();
				$('#product_item').hide();
			}
        });
		
    })
	
 </script>
 